
const { default: VueRouter } = require("vue-router")
import Router from "vue-router";
import Vue from 'vue'

Vue.use(VueRouter)

//@代表根目录的到src的路径
import Layout from '../layout/index.vue'

var routes = [
    {
        path: '/',
        redirect: './home'//重定向，就是将通过自动重写URL来将浏览器重定向至一个新的URL，也就是home页面
    },
    {
        path: '/home',
        component: Layout,
        children: [
            {
                path: '888',
                component: () => import('@/view/888.vue')
            },
            {
                path: '999',
                component: () => import('@/view/999.vue')
            }
        ]
    },

    // {
    //     path: '/home',
    //     component: () => import('../view/home'),
    //     children: [
    //         {
    //             //当/home匹配成功
    //             //@/view/view/aaa会被渲染在home的<router-view>中lu
    //             path: 'bbb',
    //             component: () => import('@/view/aaa'),
    //             children: [
    //                 {
    //                     path: 'ddd',
    //                     component: () => import('@/view/ddd')
    //                 },
    //             ]
    //         },
    //         {
    //             path: 'ccc',
    //             component: () => import('@/view/aaa')
    //         },
    //     ]
    // },
    {
        path: '/abc',
        component: () => import('@/view/aaa')
    },
    //router 匹配原则是自上向下的，谁先定义的就先匹配谁，上面所有路径都没有匹配到，就会匹配当前目录，报错404    
    {
        path: '*',//会匹配所有路径
        component: () => import('@/view/404')
    },

]


var router = new Router({
    routes
})

export default router